home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Sample.bin / FireWorksClass.java < prev    next >
Text File  |  1998-10-28  |  4KB  |  161 lines

  1. /*
  2.     A basic extension of the java.awt.Frame class
  3.  */
  4.  
  5. import java.awt.*;
  6.  
  7. import symantec.itools.multimedia.*;
  8. import symantec.itools.multimedia.Firework;
  9. public class FireWorksClass extends Frame
  10. {
  11.     public FireWorksClass()
  12.     {
  13.         // This code is automatically generated by Visual Cafe when you add
  14.         // components to the visual environment. It instantiates and initializes
  15.         // the components. To modify the code, only use code syntax that matches
  16.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  17.         // parse your Java file into its visual environment.
  18.         //{{INIT_CONTROLS
  19.         setLayout(null);
  20.         setBackground(java.awt.Color.black);
  21.         setSize(433,271);
  22.         setVisible(false);
  23.         add(firework1);
  24.         firework1.setBounds(49,21,357,173);
  25.         button1.setActionCommand("button");
  26.         button1.setLabel("Pause");
  27.         add(button1);
  28.         button1.setBounds(80,204,60,40);
  29.         button2.setActionCommand("button");
  30.         button2.setLabel("Close");
  31.         add(button2);
  32.         button2.setBounds(288,204,60,40);
  33.         button3.setActionCommand("button");
  34.         button3.setLabel("Start");
  35.         add(button3);
  36.         button3.setBounds(184,204,60,40);
  37.         setTitle("Untitled");
  38.         //}}
  39.  
  40.         //{{INIT_MENUS
  41.         //}}
  42.  
  43.         //{{REGISTER_LISTENERS
  44.         SymWindow aSymWindow = new SymWindow();
  45.         this.addWindowListener(aSymWindow);
  46.         SymAction lSymAction = new SymAction();
  47.         button1.addActionListener(lSymAction);
  48.         button3.addActionListener(lSymAction);
  49.         button2.addActionListener(lSymAction);
  50.         //}}
  51.     }
  52.  
  53.     public FireWorksClass(String title)
  54.     {
  55.         this();
  56.         setTitle(title);
  57.     }
  58.  
  59.  
  60.     public void addNotify()
  61.     {
  62.         // Record the size of the window prior to calling parents addNotify.
  63.         Dimension d = getSize();
  64.         
  65.         super.addNotify();
  66.  
  67.         if (fComponentsAdjusted)
  68.             return;
  69.  
  70.         // Adjust components according to the insets
  71.         Insets insets = getInsets();
  72.         setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
  73.         Component components[] = getComponents();
  74.         for (int i = 0; i < components.length; i++)
  75.         {
  76.             Point p = components[i].getLocation();
  77.             p.translate(insets.left, insets.top);
  78.             components[i].setLocation(p);
  79.         }
  80.         fComponentsAdjusted = true;
  81.     }
  82.  
  83.     // Used for addNotify check.
  84.     boolean fComponentsAdjusted = false;
  85.  
  86.     //{{DECLARE_CONTROLS
  87.     symantec.itools.multimedia.Firework firework1 = new symantec.itools.multimedia.Firework();
  88.     java.awt.Button button1 = new java.awt.Button();
  89.     java.awt.Button button2 = new java.awt.Button();
  90.     java.awt.Button button3 = new java.awt.Button();
  91.     //}}
  92.  
  93.     //{{DECLARE_MENUS
  94.     //}}
  95.  
  96.     class SymWindow extends java.awt.event.WindowAdapter
  97.     {
  98.         public void windowClosing(java.awt.event.WindowEvent event)
  99.         {
  100.             Object object = event.getSource();
  101.             if (object == FireWorksClass.this)
  102.                 Frame1_WindowClosing(event);
  103.         }
  104.     }
  105.     
  106.     void Frame1_WindowClosing(java.awt.event.WindowEvent event)
  107.     {
  108.         //hide();         // hide the Frame
  109.         dispose();
  110.     }
  111.  
  112.     class SymAction implements java.awt.event.ActionListener
  113.     {
  114.         public void actionPerformed(java.awt.event.ActionEvent event)
  115.         {
  116.             Object object = event.getSource();
  117.             if (object == button1)
  118.                 button1_Action(event);
  119.             else if (object == button3)
  120.                 button3_Action(event);
  121.             else if (object == button2)
  122.                 button2_Action(event);
  123.         }
  124.     }
  125.  
  126.     void button1_Action(java.awt.event.ActionEvent event)
  127.     {
  128.         // to do: code goes here.
  129.              
  130.         //{{CONNECTION
  131.         // Freeze all rockets
  132.         {
  133.             firework1.freezeRockets();
  134.         }
  135.         //}}
  136.     }
  137.  
  138.     void button3_Action(java.awt.event.ActionEvent event)
  139.     {
  140.         // to do: code goes here.
  141.              
  142.         //{{CONNECTION
  143.         // Unfreeze all rockets
  144.         {
  145.             firework1.unfreezeRockets();
  146.         }
  147.         //}}
  148.     }
  149.  
  150.     void button2_Action(java.awt.event.ActionEvent event)
  151.     {
  152.         // to do: code goes here.
  153.              
  154.         //{{CONNECTION
  155.         // Hide the Frame
  156.         setVisible(false);
  157.         dispose();
  158.         //}}
  159.     }
  160. }
  161.